<%--
  Created by IntelliJ IDEA.
  User: lt
  Date: 2021/3/30
  Time: 15:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<html>
<head>
    <title>规则数据导入</title>
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>

    <!--右侧主体区域-->
    <div class="layui-body" >
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">服务与交易信息</li>
                <li>老人去世信息</li>
                <li>老人住院信息</li>
            </ul>
            <div class="layui-tab-content">

                <%-----------服务与交易信息导入-----------%>
                <div id="CareAndDealDiv" class="layui-tab-item layui-show">
                    <div style="margin-top: 20px">
                        <form class="layui-form" id="dataImportForm"  method="post">
                            <div class="layui-form-item">
                                <div class="layui-inline" >
                                    护理评估申请表导入
                                    <button type="button" class="layui-btn " id="estimate_apply"><i class="layui-icon"></i>上传文件</button>
                                </div>
                                <div class="layui-inline" >
                                    护理评估结果表导入
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn" id="estimate_result"><i class="layui-icon"></i>上传文件</button>
                                    </div>
                                </div>
                                <div class="layui-inline" >
                                    护理计划表导入
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn"  id="care_plan"><i class="layui-icon"></i>上传文件</button>
                                    </div>
                                </div>
                                <div class="layui-inline" >
                                    护理内容表导入
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn" id="care_content"><i class="layui-icon"></i>上传文件</button>
                                    </div>
                                </div>
                                <div class="layui-inline" >
                                    护理交易记录导入
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn" id="care_deal"><i class="layui-icon"></i>上传文件</button>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <select id="tableName">
                                            <option value="">请选择表类型</option>
                                            <option value="1">护理评估申请表</option>
                                            <option value="2">护理评估结果表</option>
                                            <option value="3">护理计划表</option>
                                            <option value="4">护理内容表</option>
                                            <option value="5">护理交易记录表</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" placeholder="请输入年份" id="year">
                                    </div>
                                </div>
                            </div>

                        </form>

                        <div class="layui-inline">
                            <button class="layui-btn" id="search_btn" data-type="reload">查询</button>
                        </div>






                        <table class="layui-table" id="monthList">

                        </table>
                    </div>


                </div>
                <%-----------老人去世信息-----------%>
                <div id="ElderDeadDiv" class="layui-tab-item">
                    <div style="margin-top: 20px">
                        <form class="layui-form"  method="post">
                            <div class="layui-form-item">
                                <div class="layui-inline" >
                                    老人去世信息导入
                                    <button type="button" class="layui-btn " id="elder_dead"><i class="layui-icon"></i>上传文件</button>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" placeholder="请输入年份" id="dead_year">
                                    </div>
                                </div>
                            </div>
                        </form>

                        <div class="layui-inline">
                            <button class="layui-btn" id="search_btn1" data-type="reload">查询</button>
                        </div>

                        <table class="layui-table" id="deadMonthList">

                        </table>
                    </div>
                </div>
                <%-----------老人住院信息-----------%>
                <div id="ElderHospitalDiv" class="layui-tab-item">
                    <div style="margin-top: 20px">
                        <form class="layui-form"  method="post">
                            <div class="layui-form-item">
                                <div class="layui-inline" >
                                    老人住院信息导入
                                    <button type="button" class="layui-btn " id="elder_hospital"><i class="layui-icon"></i>上传文件</button>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" placeholder="请输入年份" id="hospital_year">
                                    </div>
                                </div>
                            </div>
                        </form>
                        <div class="layui-inline">
                            <button class="layui-btn" id="search_btn2" data-type="reload">查询</button>
                        </div>

                        <table class="layui-table" id="hospitalMonthList">

                        </table>
                    </div>
                </div>


            </div>
        </div>
    </div>

    <!--底部-->
    <div id="footer"></div>
    <%--<script src="${webPath}/js/permission/auth/permList.js"></script>--%>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>

    <%--前端查询数据库内已上传月份数据表格    --%>
    <script>
        layui.use('table',function (){
            var table=layui.table;
            //服务与交易月份
            table.render({
                elem: "#monthList",
                url: "/toStaticDataImport/selectmonth/",
                id:"importStatus",
                width:500,
                where:{
                    tableName:'',
                    year:''
                }
                ,parseData: function(result){ //result 即为原始返回的数据
                    console.log(result);
                    return {
                        "code": 0, //解析接口状态
                        "msg": "", //解析提示文本
                        "count": result.total, //解析数据长度
                        "data": result.list, //解析数据列表

                    }
                }
                ,cols:[[
                    {field:'mon' ,title:'已导入的月份',fixed:'left'}
                ]]
            });
            //老人去世月份
            table.render({
                elem: "#deadMonthList",
                url: "/toStaticDataImport/deadmonth",
                id:"deadMonth",
                width:500,
                where:{
                    year:''
                }
                ,parseData: function(result){ //result 即为原始返回的数据
                    console.log(result);
                    return {
                        "code": 0, //解析接口状态
                        "msg": "", //解析提示文本
                        "count": result.total, //解析数据长度
                        "data": result.list, //解析数据列表

                    }
                }
                ,cols:[[
                    {field:'mon' ,title:'已导入的月份',fixed:'left'}
                ]]
            });
            //老人住院月份
            table.render({
                elem: "#hospitalMonthList",
                url: "/toStaticDataImport/hospitalmonth",
                id:"hospitalMonth",
                width:500,
                where:{
                    year:''
                }
                ,parseData: function(result){ //result 即为原始返回的数据
                    console.log(result);
                    return {
                        "code": 0, //解析接口状态
                        "msg": "", //解析提示文本
                        "count": result.total, //解析数据长度
                        "data": result.list, //解析数据列表

                    }
                }
                ,cols:[[
                    {field:'mon' ,title:'已导入的月份',fixed:'left'}
                ]]
            });

            //服务与交易月份导入查询
            var $=layui.$,active={
                reload:function (){
                    var tableName=$("#tableName").val();
                    var year=$("#year").val();
                    console.log(tableName)

                    table.reload('importStatus',{
                        url:"/toStaticDataImport/selectmonth",
                        page:{
                            curr:1
                        }
                        ,where: {
                            tableName:tableName,
                            year:year
                        },
                        success:function (res){
                            console.log(res)
                        }
                    });
                }
            };
            //老人去世月份信息查询
            var $=layui.$,active1={
                reload:function (){
                    var year=$("#dead_year").val();

                    table.reload('deadMonth',{
                        url:"/toStaticDataImport/deadmonth",
                        page:{
                            curr:1
                        }
                        ,where: {
                            year:year
                        },
                        success:function (res){
                            console.log(res)
                        }
                    });
                }
            };
            //老人住院月份信息查询
            var $=layui.$,active2={
                reload:function (){
                    var year=$("#hospital_year").val();

                    table.reload('hospitalMonth',{
                        url:"/toStaticDataImport/hospitalmonth",
                        page:{
                            curr:1
                        }
                        ,where: {
                            year:year
                        },
                        success:function (res){
                            console.log(res)
                        }
                    });
                }
            };

            //搜索指定表某年数据导入情况
            $("#search_btn").on('click',function (){
                var type=$(this).data('type');
                active[type]?active[type].call(this):'';
            });

            $("#search_btn1").on('click',function (){
                var type=$(this).data('type');
                active1[type]?active1[type].call(this):'';
            });

            $("#search_btn2").on('click',function (){
                var type=$(this).data('type');
                active2[type]?active2[type].call(this):'';
            });


        });
    </script>

    <!-- 导入上传功能js文件 -->
    <script>
        layui.use('upload', function(){
            var $ = layui.jquery,upload = layui.upload;
            //上传评估申请表文件
            upload.render({
                elem: '#estimate_apply'
                ,url: '/toStaticDataImport/estimateApply' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });
            //上传评估结果表文件
            upload.render({
                elem: '#estimate_result'
                ,url: '/toStaticDataImport/estimateResult' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });
            //上传护理计划表文件
            upload.render({
                elem: '#care_plan'
                ,url: '/toStaticDataImport/upload' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });

            //上传护理内容表文件
            upload.render({
                elem: '#care_content'
                ,url: '/toStaticDataImport/careContent/' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });

            //上传护理交易记录表文件
            upload.render({
                elem: '#care_deal'
                ,url: '/toStaticDataImport/careDeal' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });

            //上传老人去世信息
            upload.render({
                elem: '#elder_dead'
                ,url: '/toStaticDataImport/elderDead' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });

            //上传老人住院信息
            upload.render({
                elem: '#elder_hospital'
                ,url: '/toStaticDataImport/elderHospital' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res);
                }
            });

        });
    </script>
<%--    <script type="text/javascript" src="${webPath}/js/StaticDataImport/StaticDataImport.js"></script>--%>



</div>
</body>
</html>
